/*
 *  Copyright 2012 yura.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

/*
 * DocGenerationPanel.java
 *
 * Created on 13.09.2012, 20:33:22
 */

package org.opu.odg.m_ui;

import java.awt.BorderLayout;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.ResourceBundle;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.opu.odg.dg.DocumentGeneraionService;
import org.opu.odg.dg.GenerationSettings;
import org.opu.odg.dg.incomingdata.ContentDescription;
import org.opu.odg.dg.incomingdata.CustomContentDescription;
import org.opu.odg.dg.incomingdata.GlobalVariables;
import org.opu.odg.dg.logicbeans.Template;
import org.opu.odg.dg.question.CustomContentQuestion;
import org.opu.odg.dg.question.Question;
import org.opu.odg.dg.question.TextQuestion;
import org.opu.odg.dg.util.XmlSerializator;
import org.opu.odg.m_ui.util.UIUtil;

/**
 *
 * @author yura
 */
public class DocGenerationPanel extends javax.swing.JDialog {
    private ResourceBundle bundle = ResourceBundle.getBundle("org.opu.odg.m_ui.Bundle");

    private DocumentGeneraionService generaionService;
    private Template template;

    private ArrayList<Question<?>> questionDataList;
    private Map<Question<?>, String[]> answers = new HashMap<Question<?>, String[]>();

    /** Creates new form DocGenerationPanel */
    public DocGenerationPanel(java.awt.Frame parent, boolean modal,
            DocumentGeneraionService generaionService, Template template)
            throws IOException {
        super(parent, modal);
        this.template = template;
        this.generaionService = generaionService;
        questionDataList = new ArrayList<Question<?>>(template.getTemplateQuestions().getQuestionList());
        initComponents();

        textQuestionPanel.add(textQuestionTxt, BorderLayout.NORTH);
        questionAnswerPanel.add(textQuestionPanel);
        textQuestionTxt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                applyBtnActionPerformed(evt);
                questionsList.setSelectedIndex(questionsList.getSelectedIndex());
            }
        });

        questionsList.addListSelectionListener(new ListSelectionListener() {

            public void valueChanged(ListSelectionEvent e) {
                Object selectedValue = questionsList.getSelectedValue();
                showBtn.setVisible(false);
                if (selectedValue != null) {
                    questionAnswerPanel.setVisible(true);
                    applyBtn.setVisible(true);
                    if (selectedValue instanceof TextQuestion) {
                        contentPanel.setVisible(false);
                        textQuestionPanel.setVisible(true);

                        textQuestionTxt.setText("");
                        String answer = ((TextQuestion) selectedValue).getQuestionAnswer();
                        if (answer != null) {
                            textQuestionTxt.setText(answer);
                        }
                    } else if (selectedValue instanceof CustomContentQuestion) {
                        contentPanel.setVisible(true);
                        textQuestionPanel.setVisible(false);

                        headerText.setText("");
                        contentText.setText("");
                        
                        String[] get = answers.get(selectedValue);
                        if (get != null) {
                            showBtn.setVisible(true);
                            headerText.setText(get[0]);
                            contentText.setText(get[1]);
                        }
                    } else {
                        questionAnswerPanel.setVisible(false);
                        applyBtn.setVisible(false);
                    }
                    questionAnswerPanelBorder.setTitle(selectedValue.toString());
                    questionAnswerPanel.repaint();
                }
            }
        });

        questionsList.setCellRenderer(new QuestionListCellRenderer());

        questionAnswerPanel.setVisible(false);
        contentPanel.setVisible(false);
        textQuestionPanel.setVisible(false);
        generateBtn.setEnabled(false);
        applyBtn.setVisible(false);
        showBtn.setVisible(false);

        setLocationRelativeTo(null);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        questionsScrollPane = new javax.swing.JScrollPane();
        questionsList = new javax.swing.JList();
        bottomPanel = new javax.swing.JPanel();
        cancelBtn = new javax.swing.JButton();
        generateBtn = new javax.swing.JButton();
        centerPanel = new javax.swing.JPanel();
        questionAnswerPanel = new javax.swing.JPanel();
        contentPanel = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        cellDelimeterLbl = new javax.swing.JLabel();
        cellDelimeterTxtBx = new javax.swing.JTextField();
        cellDelimeterChBx = new javax.swing.JCheckBox();
        lineDelimeterLbl = new javax.swing.JLabel();
        lineDelimeterTxtBx = new javax.swing.JTextField();
        lineDelimeterChBx = new javax.swing.JCheckBox();
        jPanel2 = new javax.swing.JPanel();
        headerScrollPane = new javax.swing.JScrollPane();
        headerText = new javax.swing.JTextArea();
        jPanel3 = new javax.swing.JPanel();
        contnentScrollPane = new javax.swing.JScrollPane();
        contentText = new javax.swing.JTextArea();
        jPanel5 = new javax.swing.JPanel();
        showBtn = new javax.swing.JButton();
        applyBtn = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle(bundle.getString("generateDocument.title")); // NOI18N

        questionsList.setModel(new javax.swing.AbstractListModel() {
            public int getSize() { return questionDataList.size(); }
            public Object getElementAt(int i) { return questionDataList.get(i); }
        });
        questionsList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        questionsList.setPreferredSize(new java.awt.Dimension(140, 56));
        questionsScrollPane.setViewportView(questionsList);

        getContentPane().add(questionsScrollPane, java.awt.BorderLayout.LINE_START);

        cancelBtn.setText(bundle.getString("cancel")); // NOI18N
        cancelBtn.setToolTipText(bundle.getString("cancel")); // NOI18N
        cancelBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelBtnActionPerformed(evt);
            }
        });
        bottomPanel.add(cancelBtn);

        generateBtn.setText(bundle.getString("generateDocument.generate")); // NOI18N
        generateBtn.setToolTipText(bundle.getString("generateDocument.generate")); // NOI18N
        generateBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                generateBtnActionPerformed(evt);
            }
        });
        bottomPanel.add(generateBtn);

        getContentPane().add(bottomPanel, java.awt.BorderLayout.PAGE_END);

        centerPanel.setLayout(new java.awt.BorderLayout());

        questionAnswerPanel.setBorder(questionAnswerPanelBorder);
        questionAnswerPanel.setLayout(new javax.swing.BoxLayout(questionAnswerPanel, javax.swing.BoxLayout.LINE_AXIS));

        cellDelimeterLbl.setText(bundle.getString("generateDocument.cell_delim")); // NOI18N

        cellDelimeterChBx.setText(bundle.getString("generateDocument.use_tabs")); // NOI18N
        cellDelimeterChBx.setToolTipText(bundle.getString("generateDocument.use_tabs")); // NOI18N
        cellDelimeterChBx.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cellDelimeterChBxActionPerformed(evt);
            }
        });

        lineDelimeterLbl.setText(bundle.getString("generateDocument.line_delim")); // NOI18N

        lineDelimeterChBx.setText(bundle.getString("generateDocument.use_line_break")); // NOI18N
        lineDelimeterChBx.setToolTipText(bundle.getString("generateDocument.use_line_break")); // NOI18N
        lineDelimeterChBx.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lineDelimeterChBxActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(lineDelimeterLbl, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cellDelimeterLbl, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(lineDelimeterTxtBx)
                    .addComponent(cellDelimeterTxtBx, javax.swing.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(lineDelimeterChBx, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cellDelimeterChBx, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE))
                .addContainerGap(49, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cellDelimeterLbl)
                    .addComponent(cellDelimeterTxtBx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cellDelimeterChBx))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lineDelimeterLbl)
                    .addComponent(lineDelimeterTxtBx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lineDelimeterChBx))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setLayout(new java.awt.BorderLayout());

        headerScrollPane.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("generateDocument.header"))); // NOI18N

        headerText.setColumns(20);
        headerText.setRows(5);
        headerScrollPane.setViewportView(headerText);

        jPanel2.add(headerScrollPane, java.awt.BorderLayout.CENTER);

        contnentScrollPane.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("generateDocument.content"))); // NOI18N

        contentText.setColumns(20);
        contentText.setRows(5);
        contnentScrollPane.setViewportView(contentText);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(contnentScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(contnentScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout contentPanelLayout = new javax.swing.GroupLayout(contentPanel);
        contentPanel.setLayout(contentPanelLayout);
        contentPanelLayout.setHorizontalGroup(
            contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(contentPanelLayout.createSequentialGroup()
                .addGap(12, 12, 12)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE)
                .addGap(12, 12, 12))
            .addGroup(contentPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        contentPanelLayout.setVerticalGroup(
            contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(contentPanelLayout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        questionAnswerPanel.add(contentPanel);

        centerPanel.add(questionAnswerPanel, java.awt.BorderLayout.CENTER);

        jPanel5.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));

        showBtn.setText(bundle.getString("generateDocument.show")); // NOI18N
        showBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                showBtnActionPerformed(evt);
            }
        });
        jPanel5.add(showBtn);

        applyBtn.setText(bundle.getString("generateDocument.apply")); // NOI18N
        applyBtn.setToolTipText(bundle.getString("generateDocument.apply")); // NOI18N
        applyBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                applyBtnActionPerformed(evt);
            }
        });
        jPanel5.add(applyBtn);

        centerPanel.add(jPanel5, java.awt.BorderLayout.PAGE_END);

        getContentPane().add(centerPanel, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBtnActionPerformed
        dispose();
    }//GEN-LAST:event_cancelBtnActionPerformed

    private void applyBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_applyBtnActionPerformed
        Object selectedValue = questionsList.getSelectedValue();
        if (selectedValue != null && selectedValue instanceof Question) {
            try {
                Question question = (Question) selectedValue;
                if (question instanceof TextQuestion) {
                    question.setQuestionAnswer(textQuestionTxt.getText());
                } else if (question instanceof CustomContentQuestion) {
                    String headers[];
                    String datap[][];

                    if (!headerText.getText().isEmpty()) {
                        headers = headerText.getText().split(cellDelimeterTxtBx.getText());
                    } else {
                        ContentDescription get = template.getMetaInf()
                                .getContents().get(question.getName());
                        if (get == null) {
                            throw new NullPointerException("Content does not "
                                    + "exist in metainf.xml.");
                        }
                        if (get instanceof CustomContentDescription) {
                            headers = ((CustomContentDescription)get).getHeaders();
                        } else {
                            throw new IllegalArgumentException("Content is not"
                                    + " custom content.");
                        }
                    }
                    if (headers == null) {
                        throw new NullPointerException("Can't init header");
                    }

                    datap = new String[0][headers.length];

                    if (!contentText.getText().isEmpty()) {
                        String[] split = contentText.getText().split(lineDelimeterTxtBx.getText());
                        datap = new String[split.length][];
                        for (int i = 0; i < split.length; i++) {
                            datap[i] = split[i].split(cellDelimeterTxtBx.getText());
                        }
                    }

                    question.setQuestionAnswer(new CustomContentDescription(headers, datap));
                    answers.put(question, new String[]{headerText.getText(), contentText.getText()});
                }

                questionsList.repaint();
                showBtn.setVisible(question instanceof CustomContentQuestion);

                for (Question<?> question1 : questionDataList) {
                    if (question1.getQuestionAnswer() == null) {
                        return;
                    }
                }
                generateBtn.setEnabled(true);
            } catch (Exception ex) {
                ex.printStackTrace(System.out);
                UIUtil.niceEx(ex, getTitle(), "");
            }
        }
    }//GEN-LAST:event_applyBtnActionPerformed

    private void cellDelimeterChBxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cellDelimeterChBxActionPerformed
        cellDelimeterTxtBx.setEnabled(!cellDelimeterChBx.isSelected());
        cellDelimeterTxtBx.setText(cellDelimeterChBx.isSelected() ? "\\t" : ";");
    }//GEN-LAST:event_cellDelimeterChBxActionPerformed

    private void lineDelimeterChBxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lineDelimeterChBxActionPerformed
        lineDelimeterTxtBx.setEnabled(!lineDelimeterChBx.isSelected());
        lineDelimeterTxtBx.setText(lineDelimeterChBx.isSelected() ? "\\r?\\n" : "|");
    }//GEN-LAST:event_lineDelimeterChBxActionPerformed

    private void showBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showBtnActionPerformed
        Object selectedValue = questionsList.getSelectedValue();
        if (selectedValue != null && selectedValue instanceof CustomContentQuestion) {
            CustomContentQuestion question = (CustomContentQuestion) selectedValue;
            final CustomContentDescription questionAnswer = question.getQuestionAnswer();
            if (questionAnswer != null) {
                JTable table = new JTable(new AbstractTableModel() {
                    public String getColumnName(int column) { return questionAnswer.getHeaders()[column].toString(); }
                    public int getRowCount() { return questionAnswer.getData().length; }
                    public int getColumnCount() { return questionAnswer.getHeaders().length; }
                    public Object getValueAt(int row, int col) {
                        try {
                            return questionAnswer.getData()[row][col];
                        } catch (Exception e) {
                            return e;
                        }
                    }
                });

                JDialog d = new JDialog(this, "show", true);
                d.getContentPane().add(new JScrollPane(table));
                d.pack();
                d.setLocationRelativeTo(null);
                d.setVisible(true);
            }
        }
    }//GEN-LAST:event_showBtnActionPerformed

    private void generateBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateBtnActionPerformed
        JFileChooser fch = new JFileChooser();
        fch.setDialogType(JFileChooser.SAVE_DIALOG);
        fch.setFileSelectionMode(JFileChooser.FILES_ONLY);
        int returnVal = fch.showOpenDialog(this);

        if (returnVal != JFileChooser.APPROVE_OPTION) {
            return;
        }
        
        FileOutputStream fout = null;
        FileOutputStream gvFout = null;
        Properties vars = new Properties();
        Map<String, CustomContentDescription> contents =
                    new HashMap<String, CustomContentDescription>();

        for (Question<?> question : questionDataList) {
            if (question instanceof TextQuestion) {
                vars.put(question.getName(), question.getQuestionAnswer());
            } else if (question instanceof CustomContentQuestion) {
                contents.put(question.getName(),
                        ((CustomContentQuestion)question).getQuestionAnswer());
            }
        }

        File selectedFile = fch.getSelectedFile();
        try {
            GenerationSettings gs = new GenerationSettings(template.getId(),
                    new GlobalVariables(vars), contents);

            File xmlFile = new File(selectedFile.getParent(), FilenameUtils
                    .getBaseName(selectedFile.getName()) + ".xml");

            XmlSerializator.write(gs, gvFout = new FileOutputStream(xmlFile));
            generaionService.generateDocument(gs, 
                    fout = FileUtils.openOutputStream(selectedFile));

            UIUtil.openInFileBrowser(selectedFile, getTitle());
        } catch (Exception ex) {
            ex.printStackTrace(System.out);
            UIUtil.niceEx(ex, getTitle(), "");
        } finally {
            IOUtils.closeQuietly(fout);
            IOUtils.closeQuietly(gvFout);
        }

    }//GEN-LAST:event_generateBtnActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton applyBtn;
    private javax.swing.JPanel bottomPanel;
    private javax.swing.JButton cancelBtn;
    private javax.swing.JCheckBox cellDelimeterChBx;
    private javax.swing.JLabel cellDelimeterLbl;
    private javax.swing.JTextField cellDelimeterTxtBx;
    private javax.swing.JPanel centerPanel;
    private javax.swing.JPanel contentPanel;
    private javax.swing.JTextArea contentText;
    private javax.swing.JScrollPane contnentScrollPane;
    private javax.swing.JButton generateBtn;
    private javax.swing.JScrollPane headerScrollPane;
    private javax.swing.JTextArea headerText;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JCheckBox lineDelimeterChBx;
    private javax.swing.JLabel lineDelimeterLbl;
    private javax.swing.JTextField lineDelimeterTxtBx;
    private javax.swing.JPanel questionAnswerPanel;
    private javax.swing.JList questionsList;
    private javax.swing.JScrollPane questionsScrollPane;
    private javax.swing.JButton showBtn;
    // End of variables declaration//GEN-END:variables

    private JPanel textQuestionPanel = new JPanel(new BorderLayout());
    private JTextField textQuestionTxt = new JTextField();

    private TitledBorder questionAnswerPanelBorder = BorderFactory.createTitledBorder("question");

}
